<template>
  <!-- 门禁-参数模板 -->
  <div class="consumer_machine">
    <el-row>
      <dragdrop :width="0" :widthLeft="'150px'">
        <template slot="left">
          <div class="left_shuju">
            <div class="grid-content bg-purple">
              <div class="header_title">
                <span>模板数据</span>
              </div>
              <div class="addtemplate" v-if="isauth('access_p_edit')">
                <el-button
                  title="新增"
                  type="primary"
                  size="mini"
                  @click="addtForm"
                  icon="el-icon-plus"
                >新增模板</el-button>
              </div>
              <el-table
                :data="tableData"
                border
                @row-click="rowClick"
                highlight-current-row
                style="width: 100%"
                :header-cell-style="headFirst"
                :height="'calc(100vh - 220px)'"
                :cell-style="(res) => headFirst_col(res, [], 2)"
              >
                <el-table-column align="center" prop="templateName" label="模板名称"></el-table-column>
                <el-table-column label="操作" align="center" v-if="isauth('access_p_edit')">
                  <template slot-scope="scope">
                    <el-button type="text" size="mini" @click.stop="eidtDate(scope.row)">修改密码</el-button>
                    <el-button
                      v-if="userType === '1' || userType == '50' ? true : false"
                      type="text"
                      size="mini"
                      @click.stop="resetDate(scope.row)"
                    >重置密码</el-button>
                    <el-button
                      type="text"
                      size="mini"
                      @click.stop="deleteDate(scope.row)"
                      style="color: red"
                    >删除</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </div>
        </template>
        <template slot="right">
          <div class="right_shuju">
            <div class="grid-content bg-purple-light" v-if="isShow">
              <el-tabs type="border-card" v-model="activeName" @tab-click="handleClick">
                <!-- 基础设置 -->
                <el-tab-pane label="基础参数" name="third">
                  <el-form
                    :model="ruleForm"
                    :inline="true"
                    :rules="rules"
                    ref="ruleForm"
                    class="demo-ruleForm"
                  >
                    <el-row>
                      <el-col :span="12">
                        <el-form-item label="通行名单卡有效天数开始计算时间" prop="effectiveStartDate">
                          <el-date-picker
                            v-model="ruleForm.effectiveStartDate"
                            type="date"
                            placeholder="选择日期"
                            value-format="yyyy-MM-dd"
                            size="mini"
                            class="picker_width"
                            :clearable="false"
                          ></el-date-picker>
                        </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="名单分区字节序号:" prop="rosterSubarea">
                          <el-select
                            v-model="ruleForm.rosterDistrictByteOrder"
                            placeholder="请选择"
                            size="mini"
                            style="width: 80px"
                            disabled
                          >
                            <el-option
                              v-for="item in rosterSubareaoption"
                              :key="item.value"
                              :label="item.label"
                              :value="item.value"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <!-- 1 -->
                    <el-row>
                      <el-col :span="8">
                        <el-form-item label="门1开门时长" prop="openingTimeDoor1">
                          <el-input-number
                            v-model="ruleForm.openingTimeDoor1"
                            :min="0"
                            :max="255"
                            label
                            size="mini"
                            style="width: 100px"
                            :precision="0"
                          ></el-input-number>
                          <span>秒</span>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="启用按钮1" prop="buttonCheck1">
                          <el-checkbox v-model="ruleForm.buttonCheck1"></el-checkbox>
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="门1读头类型" prop="readHeadType1">
                          <el-select
                            v-model="ruleForm.readHeadType1"
                            size="mini"
                            style="width: 108px"
                          >
                            <el-option
                              :label="item.label"
                              :value="item.value"
                              v-for="item in readHeadTypeOption"
                              :key="item.value"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <!-- 2 -->
                    <el-row>
                      <!-- buttonCheck1 -->
                      <el-col :span="8">
                        <el-form-item label="门2开门时长" prop="openingTimeDoor2">
                          <el-input-number
                            v-model="ruleForm.openingTimeDoor2"
                            :min="0"
                            :max="255"
                            label
                            size="mini"
                            style="width: 100px"
                            :precision="0"
                          ></el-input-number>
                          <span>秒</span>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="启用按钮2" prop="buttonCheck2">
                          <el-checkbox v-model="ruleForm.buttonCheck2"></el-checkbox>
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="门2读头类型" prop="readHeadType2">
                          <el-select
                            v-model="ruleForm.readHeadType2"
                            size="mini"
                            style="width: 108px"
                          >
                            <el-option
                              :label="item.label"
                              :value="item.value"
                              v-for="item in readHeadTypeOption"
                              :key="item.value"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <!-- 3 -->
                    <el-row>
                      <el-col :span="6">
                        <el-form-item label="启用门磁1" prop="doorMagneticCheck1">
                          <el-checkbox v-model="ruleForm.doorMagneticCheck1"></el-checkbox>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="门磁类型1" prop="doorMagneticType1">
                          <el-select
                            v-model="ruleForm.doorMagneticType1"
                            size="mini"
                            style="width: 100px"
                            :disabled="!ruleForm.doorMagneticCheck1"
                          >
                            <el-option
                              :label="item.label"
                              :value="item.value"
                              v-for="item in optionsEntranceStatus"
                              :key="item.value"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="启用门磁2" prop="doorMagneticCheck2">
                          <el-checkbox v-model="ruleForm.doorMagneticCheck2"></el-checkbox>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="门磁类型2" prop="doorMagneticType2">
                          <el-select
                            v-model="ruleForm.doorMagneticType2"
                            size="mini"
                            style="width: 100px"
                            :disabled="!ruleForm.doorMagneticCheck2"
                          >
                            <el-option
                              :label="item.label"
                              :value="item.value"
                              v-for="item in optionsEntranceStatus"
                              :key="item.value"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <!-- 4 -->
                    <el-row>
                      <el-col :span="6">
                        <el-form-item label="门1对应的继电器" prop="relayDoorCode1">
                          <el-input-number
                            v-model="ruleForm.relayDoorCode1"
                            :min="1"
                            :max="4"
                            label
                            size="mini"
                            style="width: 90px"
                          ></el-input-number>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="门2对应的继电器" prop="relayDoorCode1121">
                          <el-input-number
                            v-model="ruleForm.relayDoorCode2"
                            :min="1"
                            :max="4"
                            label
                            size="mini"
                            style="width: 90px"
                          ></el-input-number>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="门1进出方向" prop="doorPassOut1">
                          <el-select
                            v-model="ruleForm.doorPassOut1"
                            size="mini"
                            style="width: 100px"
                          >
                            <el-option
                              :label="item.label"
                              :value="item.value"
                              v-for="item in doorPassOutOption"
                              :key="item.value"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="门2进出方向" prop="doorPassOut2">
                          <el-select
                            v-model="ruleForm.doorPassOut2"
                            size="mini"
                            style="width: 100px"
                          >
                            <el-option
                              :label="item.label"
                              :value="item.value"
                              v-for="item in doorPassOutOption"
                              :key="item.value"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                    </el-row>

                    <!-- 开门验证 -->
                    <el-row>
                      <el-col :span="6">
                        <el-form-item label="读头1开门验证" prop="readHeadVerify1">
                          <el-select
                            v-model="ruleForm.readHeadVerify1"
                            size="mini"
                            style="width: 108px"
                          >
                            <el-option
                              :label="item.label"
                              :value="item.value"
                              v-for="item in readHeadVerifyOption"
                              :key="item.value"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="读头2开门验证" prop="readHeadVerify2">
                          <el-select
                            v-model="ruleForm.readHeadVerify2"
                            size="mini"
                            style="width: 108px"
                          >
                            <el-option
                              :label="item.label"
                              :value="item.value"
                              v-for="item in readHeadVerifyOption"
                              :key="item.value"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="门1重复刷卡" prop="doorRepeatSwipeCardTime1">
                          <el-input-number
                            v-model="ruleForm.doorRepeatSwipeCardTime1"
                            :min="0"
                            :max="255"
                            label
                            size="mini"
                            style="width: 100px"
                            :precision="0"
                          ></el-input-number>
                          <span>分</span>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="门2重复刷卡" prop="doorRepeatSwipeCardTime2">
                          <el-input-number
                            v-model="ruleForm.doorRepeatSwipeCardTime2"
                            :min="0"
                            :max="255"
                            label
                            size="mini"
                            style="width: 100px"
                            :precision="0"
                          ></el-input-number>
                          <span>分</span>
                        </el-form-item>
                      </el-col>
                    </el-row>

                    <!-- 门模式 -->
                    <el-row>
                      <el-col :span="6">
                        <el-form-item label="门模式" prop="doorModel">
                          <el-select v-model="ruleForm.doorModel" size="mini" style="width: 108px">
                            <el-option
                              :label="item.label"
                              :value="item.value"
                              v-for="item in doorModelOption"
                              :key="item.value"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="AB门互锁" prop="abdoorEntrance">
                          <el-checkbox v-model="ruleForm.abdoorEntrance"></el-checkbox>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="双门双向防潜回" prop="twoWayDoor">
                          <el-checkbox v-model="ruleForm.twoWayDoor"></el-checkbox>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="数据满处理方式" prop="dataFullProcessingMethod">
                          <el-select
                            v-model="ruleForm.dataFullProcessingMethod"
                            size="mini"
                            style="width: 100px"
                          >
                            <el-option
                              :label="item.label"
                              :value="item.value"
                              v-for="item in dataFullProcessingMethodOption"
                              :key="item.value"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-form>
                </el-tab-pane>
                <!-- 门禁状态 -->
                <el-tab-pane label="门禁状态" name="state">
                  <el-table
                    v-loading="loading"
                    :data="entranceStatusList"
                    ref="entranceStatusList"
                    border
                    :header-cell-style="headFirst"
                    style="width: 100%"
                    height="calc(100vh - 280px)"
                :cell-style="(res) => headFirst_col(res, [], 2)"
                  >
                    <el-table-column align="center" prop="doorCode" label="门" max-width="100px"></el-table-column>
                    <el-table-column align="center" prop="order" label="序号" max-width="60"></el-table-column>
                    <el-table-column align="center" prop="isUse" label="是否启用" width="60px">
                      <template slot-scope="scope">
                        <el-checkbox v-model="scope.row.isUse"></el-checkbox>
                      </template>
                    </el-table-column>
                    <el-table-column align="center" prop="startTime" label="开始时间" min-width="70px">
                      <template slot-scope="scope">
                        <el-time-picker
                          v-model="scope.row.startTime"
                          placeholder="选择时间"
                          @change="change"
                          value-format="HH:mm"
                          format="HH:mm"
                          style="width: 100px"
                          size="mini"
                        ></el-time-picker>
                      </template>
                    </el-table-column>
                    <el-table-column align="center" prop="endTime" label="结束时间" min-width="70px">
                      <template slot-scope="scope">
                        <el-time-picker
                          v-model="scope.row.endTime"
                          placeholder="选择时间"
                          @change="change"
                          value-format="HH:mm"
                          format="HH:mm"
                          style="width: 100px"
                          size="mini"
                        ></el-time-picker>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="entranceStatus"
                      min-width="60px"
                      label="门禁状态"
                    >
                      <template slot-scope="scope">
                        <el-select v-model="scope.row.entranceStatus" placeholder="请选择" size="mini">
                          <el-option
                            v-for="item in optionsEntranceStatus"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                            size="mini"
                          ></el-option>
                        </el-select>
                      </template>
                    </el-table-column>
                  </el-table>
                </el-tab-pane>
                <!-- 正常/补班时段配置 -->
                <el-tab-pane label="正常/补班时段配置" name="second">
                  <el-tabs type="border-card" v-model="activeNormalPeriod" @tab-click="handleClick">
                    <el-tab-pane label="星期时段配置" name="normalWeek">
                      <div class="consumption_rules">
                        <div class="explanation">
                          <!-- 星期时段配置 -->
                          <el-table
                            v-loading="loading"
                            :data="weekPassTimeList"
                            ref="table"
                            border
                            :header-cell-style="headFirst"
                            height="calc(100vh - 320px)"
                            style="width: 100%"
                            :cell-style="(res) => headFirst_col(res, [], 2)"
                          >
                            <el-table-column
                              align="center"
                              prop="timeNumber"
                              label="时段"
                              min-width="100px"
                            >
                              <template slot-scope="scope">时段{{ scope.row.timeNumber }}</template>
                            </el-table-column>
                            <el-table-column
                              align="center"
                              prop="stateTime1"
                              label="开始时间1"
                              min-width="110px"
                            >
                              <template slot-scope="scope">
                                <el-time-picker
                                  v-model="scope.row.stateTime1"
                                  placeholder="选择时间"
                                  @change="change"
                                  value-format="HH:mm"
                                  format="HH:mm"
                                  style="width: 100px"
                                  size="mini"
                                ></el-time-picker>
                              </template>
                            </el-table-column>
                            <el-table-column
                              align="center"
                              prop="endTime1"
                              label="结束时间1"
                              min-width="110px"
                            >
                              <template slot-scope="scope">
                                <el-time-picker
                                  v-model="scope.row.endTime1"
                                  placeholder="选择时间"
                                  @change="change"
                                  value-format="HH:mm"
                                  format="HH:mm"
                                  style="width: 100px"
                                  size="mini"
                                ></el-time-picker>
                              </template>
                            </el-table-column>
                            <el-table-column
                              align="center"
                              prop="stateTime2"
                              label="开始时间2"
                              min-width="110px"
                            >
                              <template slot-scope="scope">
                                <el-time-picker
                                  v-model="scope.row.stateTime2"
                                  placeholder="选择时间"
                                  @change="change"
                                  value-format="HH:mm"
                                  format="HH:mm"
                                  style="width: 100px"
                                  size="mini"
                                ></el-time-picker>
                              </template>
                            </el-table-column>
                            <el-table-column
                              align="center"
                              prop="endTime2"
                              label="结束时间2"
                              min-width="110px"
                            >
                              <template slot-scope="scope">
                                <el-time-picker
                                  v-model="scope.row.endTime2"
                                  placeholder="选择时间"
                                  @change="change"
                                  value-format="HH:mm"
                                  format="HH:mm"
                                  style="width: 100px"
                                  size="mini"
                                ></el-time-picker>
                              </template>
                            </el-table-column>
                            <el-table-column
                              align="center"
                              prop="stateTime3"
                              label="开始时间3"
                              min-width="110px"
                            >
                              <template slot-scope="scope">
                                <el-time-picker
                                  v-model="scope.row.stateTime3"
                                  placeholder="选择时间"
                                  @change="change"
                                  value-format="HH:mm"
                                  format="HH:mm"
                                  style="width: 100px"
                                  size="mini"
                                ></el-time-picker>
                              </template>
                            </el-table-column>
                            <el-table-column
                              align="center"
                              prop="endTime3"
                              label="结束时间3"
                              min-width="110px"
                            >
                              <template slot-scope="scope">
                                <el-time-picker
                                  v-model="scope.row.endTime3"
                                  placeholder="选择时间"
                                  @change="change"
                                  value-format="HH:mm"
                                  format="HH:mm"
                                  style="width: 100px"
                                  size="mini"
                                ></el-time-picker>
                              </template>
                            </el-table-column>
                            <el-table-column
                              align="center"
                              prop="stateTime4"
                              label="开始时间4"
                              min-width="110px"
                            >
                              <template slot-scope="scope">
                                <el-time-picker
                                  v-model="scope.row.stateTime4"
                                  placeholder="选择时间"
                                  @change="change"
                                  value-format="HH:mm"
                                  format="HH:mm"
                                  style="width: 100px"
                                  size="mini"
                                ></el-time-picker>
                              </template>
                            </el-table-column>
                            <el-table-column
                              align="center"
                              prop="endTime4"
                              label="结束时间4"
                              min-width="110px"
                            >
                              <template slot-scope="scope">
                                <el-time-picker
                                  v-model="scope.row.endTime4"
                                  placeholder="选择时间"
                                  @change="change"
                                  value-format="HH:mm"
                                  format="HH:mm"
                                  style="width: 100px"
                                  size="mini"
                                ></el-time-picker>
                              </template>
                            </el-table-column>
                            <el-table-column
                              align="center"
                              prop="stateTime5"
                              label="开始时间5"
                              min-width="110px"
                            >
                              <template slot-scope="scope">
                                <el-time-picker
                                  v-model="scope.row.stateTime5"
                                  placeholder="选择时间"
                                  @change="change"
                                  value-format="HH:mm"
                                  format="HH:mm"
                                  style="width: 100px"
                                  size="mini"
                                ></el-time-picker>
                              </template>
                            </el-table-column>
                            <el-table-column
                              align="center"
                              prop="endTime5"
                              label="结束时间5"
                              min-width="110px"
                            >
                              <template slot-scope="scope">
                                <el-time-picker
                                  v-model="scope.row.endTime5"
                                  placeholder="选择时间"
                                  @change="change"
                                  value-format="HH:mm"
                                  format="HH:mm"
                                  style="width: 100px"
                                  size="mini"
                                ></el-time-picker>
                              </template>
                            </el-table-column>
                            <el-table-column
                              align="center"
                              prop="stateTime6"
                              label="开始时间6"
                              min-width="110px"
                            >
                              <template slot-scope="scope">
                                <el-time-picker
                                  v-model="scope.row.stateTime6"
                                  placeholder="选择时间"
                                  @change="change"
                                  value-format="HH:mm"
                                  format="HH:mm"
                                  style="width: 100px"
                                  size="mini"
                                ></el-time-picker>
                              </template>
                            </el-table-column>
                            <el-table-column
                              align="center"
                              prop="endTime6"
                              label="结束时间6"
                              min-width="110px"
                            >
                              <template slot-scope="scope">
                                <el-time-picker
                                  v-model="scope.row.endTime6"
                                  placeholder="选择时间"
                                  @change="change"
                                  value-format="HH:mm"
                                  format="HH:mm"
                                  style="width: 100px"
                                  size="mini"
                                ></el-time-picker>
                              </template>
                            </el-table-column>
                          </el-table>
                        </div>
                      </div>
                    </el-tab-pane>
                    <el-tab-pane label="假日时段配置" name="normalHoliday">
                      <!-- 假日时段配置 -->
                      <el-table
                        v-loading="loading"
                        :data="holidayPassTimeList"
                        ref="holidayPassTimeList"
                        border
                        :header-cell-style="headFirst"
                        height="calc(100vh - 320px)"
                        style="width: 100%"
                        :cell-style="(res) => headFirst_col(res, [], 2)"
                      >
                        <el-table-column
                          align="center"
                          prop="timeNumber"
                          label="时段"
                          min-width="60px"
                        >
                          <template slot-scope="scope">时段{{ scope.row.timeNumber }}</template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="stateTime1"
                          label="开始时间1"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.stateTime1"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="endTime1"
                          label="结束时间1"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.endTime1"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="stateTime2"
                          label="开始时间2"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.stateTime2"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="endTime2"
                          label="结束时间2"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.endTime2"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="stateTime3"
                          label="开始时间3"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.stateTime3"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="endTime3"
                          label="结束时间3"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.endTime3"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="stateTime4"
                          label="开始时间4"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.stateTime4"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="endTime4"
                          label="结束时间4"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.endTime4"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="stateTime5"
                          label="开始时间5"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.stateTime5"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="endTime5"
                          label="结束时间5"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.endTime5"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="stateTime6"
                          label="开始时间6"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.stateTime6"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="endTime6"
                          label="结束时间6"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.endTime6"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                      </el-table>
                    </el-tab-pane>
                  </el-tabs>
                </el-tab-pane>
                <!-- 假日配置 -->
                <el-tab-pane label="假日配置" name="holidaySetupList">
                  <el-tabs type="border-card" v-model="activeHoliday" @tab-click="handleClick">
                    <el-tab-pane label="节假日" name="holidayVacations">
                      <el-table
                        v-loading="loading"
                        :data="holidaySetupList"
                        ref="holidaySetupList"
                        border
                        :header-cell-style="headFirst"
                        height="calc(100vh - 320px)"
                        style="width: 100%"
                        :cell-style="(res) => headFirst_col(res, [], 2)"
                      >
                        <el-table-column
                          align="center"
                          prop="holidayNumber"
                          label="时段"
                          max-width="100px"
                        >
                          <template slot-scope="scope">时段{{ scope.row.holidayNumber }}</template>
                        </el-table-column>
                        <el-table-column align="center" prop="validFlag" label="是否启用" width="60px">
                          <template slot-scope="scope">
                            <el-checkbox v-model="scope.row.validFlag"></el-checkbox>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="stateDate"
                          label="开始时间"
                          min-width="60px"
                        >
                          <template slot-scope="scope">
                            <el-date-picker
                              v-model="scope.row.stateDate"
                              type="date"
                              placeholder="选择日期"
                              value-format="yyyy-MM-dd"
                              size="mini"
                              class="picker_width"
                            ></el-date-picker>
                            <!-- <el-date-picker
                      v-model="scope.row.stateDate"
                      type="datetime"
                      placeholder="选择日期时间"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      size="mini"
                      style="width:180px"
                            ></el-date-picker>-->
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="endDate"
                          label="结束时间"
                          min-width="60px"
                        >
                          <template slot-scope="scope">
                            <el-date-picker
                              v-model="scope.row.endDate"
                              type="date"
                              placeholder="选择日期"
                              value-format="yyyy-MM-dd"
                              size="mini"
                              class="picker_width"
                            ></el-date-picker>
                          </template>
                        </el-table-column>
                      </el-table>
                    </el-tab-pane>
                    <!-- 周休息日配置 -->
                    <el-tab-pane label="周休息日配置" name="restDay">
                      <el-form
                        :model="restDay"
                        :inline="true"
                        ref="ruleRestDay"
                        class="demo-ruleForm"
                      >
                        <el-row>
                          <el-col :span="6">
                            <el-form-item label prop="validFlagAll">
                              <el-checkbox v-model="restDay.validFlagAll">是否有效</el-checkbox>
                            </el-form-item>
                          </el-col>
                        </el-row>
                        <el-row>
                          <el-col :span="3">
                            <el-form-item label prop="monValidFlag">
                              <el-checkbox v-model="restDay.monValidFlag">星期一</el-checkbox>
                            </el-form-item>
                          </el-col>
                          <el-col :span="3">
                            <el-form-item label prop="tueValidFlag">
                              <el-checkbox v-model="restDay.tueValidFlag">星期二</el-checkbox>
                            </el-form-item>
                          </el-col>
                          <el-col :span="3">
                            <el-form-item label prop="wedValidFlag" width="300px">
                              <el-checkbox v-model="restDay.wedValidFlag">星期三</el-checkbox>
                            </el-form-item>
                          </el-col>
                          <el-col :span="3">
                            <el-form-item label prop="thuValidFlag">
                              <el-checkbox v-model="restDay.thuValidFlag">星期四</el-checkbox>
                            </el-form-item>
                          </el-col>
                          <el-col :span="3">
                            <el-form-item label prop="friValidFlag">
                              <el-checkbox v-model="restDay.friValidFlag">星期五</el-checkbox>
                            </el-form-item>
                          </el-col>
                          <el-col :span="3">
                            <el-form-item label prop=" satValidFlag" width="300px">
                              <el-checkbox v-model="restDay.satValidFlag">星期六</el-checkbox>
                            </el-form-item>
                          </el-col>
                          <el-col :span="3">
                            <el-form-item label prop=" sunValidFlag" width="300px">
                              <el-checkbox v-model="restDay.sunValidFlag">星期天</el-checkbox>
                            </el-form-item>
                          </el-col>
                        </el-row>
                      </el-form>
                    </el-tab-pane>
                    <!-- 例外假日配置 -->
                    <el-tab-pane label="例外假日配置" name="holidayOtherList">
                      <el-table
                        v-loading="loading"
                        :data="holidayOtherList"
                        ref="holidayOtherList"
                        border
                        :header-cell-style="headFirst"
                        height="calc(100vh - 320px)"
                        style="width: 100%"
                        :cell-style="(res) => headFirst_col(res, [], 2)"
                      >
                        <el-table-column
                          align="center"
                          prop="holidayNumber"
                          label="时段"
                          max-width="100px"
                        >
                          <template slot-scope="scope">时段{{ scope.row.holidayNumber }}</template>
                        </el-table-column>
                        <el-table-column align="center" prop="validFlag" label="是否启用" width="60px">
                          <template slot-scope="scope">
                            <el-checkbox v-model="scope.row.validFlag"></el-checkbox>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="stateDate"
                          label="开始时间"
                          min-width="60px"
                        >
                          <template slot-scope="scope">
                            <el-date-picker
                              v-model="scope.row.stateDate"
                              type="date"
                              placeholder="选择日期"
                              value-format="yyyy-MM-dd"
                              size="mini"
                              class="picker_width"
                            ></el-date-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="endDate"
                          label="结束时间"
                          min-width="60px"
                        >
                          <template slot-scope="scope">
                            <el-date-picker
                              v-model="scope.row.endDate"
                              type="date"
                              placeholder="选择日期"
                              value-format="yyyy-MM-dd"
                              size="mini"
                              class="picker_width"
                            ></el-date-picker>
                          </template>
                        </el-table-column>
                      </el-table>
                    </el-tab-pane>
                  </el-tabs>
                </el-tab-pane>
                <!-- 特殊权限配置 -->
                <el-tab-pane label="特殊权限配置" name="superUser">
                  <el-tabs type="border-card" v-model="activeUserSetupList">
                    <el-tab-pane label="超级用户" name="superUserSetupList">
                      <el-table
                        v-loading="loading"
                        :data="superUserSetupList"
                        ref="superUserSetupList"
                        border
                        :header-cell-style="headFirst"
                        height="calc(100vh - 320px)"
                        style="width: 100%"
                        :cell-style="(res) => headFirst_col(res, [], 2)"
                      >
                        <el-table-column align="center" prop="userNumber" label max-width="100px">
                          <template slot-scope="scope">
                            {{
                            scope.row.userNumber
                            }}
                          </template>
                        </el-table-column>
                        <el-table-column align="center" prop="isUse" label="是否启用" width="60px">
                          <template slot-scope="scope">
                            <el-checkbox v-model="scope.row.isUse"></el-checkbox>
                          </template>
                        </el-table-column>
                        <el-table-column align="center" prop="userPasswordOne" label="密码">
                          <template slot-scope="scope">
                            <el-input
                              v-model="scope.row.userPasswordOne"
                              placeholder="请输入内容"
                              size="mini"
                              style="width: 160px"
                            ></el-input>
                          </template>
                        </el-table-column>
                        <el-table-column align="center" prop="userPasswordTwo" label="胁迫密码">
                          <template slot-scope="scope">
                            <el-input
                              v-model="scope.row.userPasswordTwo"
                              placeholder="请输入内容"
                              size="mini"
                              style="width: 160px"
                            ></el-input>
                          </template>
                        </el-table-column>
                      </el-table>
                    </el-tab-pane>
                  </el-tabs>
                </el-tab-pane>
              </el-tabs>
              <div class="footer" v-if="isauth('access_p_edit')">
                <el-card class="box-card">
                  <div class="footerflex">
                    <div class="footer_save">
                      <el-input
                        size="mini"
                        v-model="alldatatemplatePassword"
                        show-password
                        placeholder="请输入密码后，再点保存"
                      ></el-input>
                    </div>
                    <div class="footer_save">
                      <el-button type="primary" size="mini" @click="savealldata">保存</el-button>
                    </div>
                    <div class="footer_merchant_equipment_parameters">
                      <el-button type="primary" size="mini" @click="savemerchant">重发参数模板</el-button>
                    </div>
                  </div>
                </el-card>
              </div>
            </div>
          </div>
        </template>
      </dragdrop>
    </el-row>
    <!-- 新增 -->
    <el-dialog
      :before-close="closeDialog"
      width="500px"
      center
      title="新增模板"
      :close-on-click-modal="false"
      :visible.sync="addDialogFormVisible"
    >
      <el-form :model="adddataForm" :rules="adddataRule" ref="adddataForm" label-width="80px">
        <el-form-item label="模板名称" prop="templateName">
          <el-col :span="15">
            <el-input v-model="adddataForm.templateName" placeholder="用户名称" size="mini"></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="模板密码" prop="templatePassword">
          <el-col :span="15">
            <el-input v-model="adddataForm.templatePassword" placeholder="用户密码" size="mini"></el-input>
          </el-col>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="addvisible()">取消</el-button>
        <el-button type="primary" @click="addFormSubmit()">确定</el-button>
      </span>
    </el-dialog>
    <!-- 修改 -->
    <el-dialog
      :before-close="eidtcloseDialog"
      width="500px"
      center
      title="修改模板"
      :close-on-click-modal="false"
      :visible.sync="eidtDialogFormVisible"
    >
      <el-form :model="eidtdataForm" :rules="adddataRule" ref="eidtdataForm1" label-width="90px">
        <el-form-item label="模板名称" prop="templateName">
          <el-col :span="15">
            <el-input v-model="eidtdataForm.templateName" placeholder="模板名称" size="mini"></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="新模板密码" prop="newPassword">
          <el-col :span="15">
            <el-input
              placeholder="请输入新密码"
              v-model="eidtdataForm.newPassword"
              show-password
              :disabled="eidtdataForm.changepassword === false ? true : false"
              size="mini"
            ></el-input>
          </el-col>
          <el-col :span="5" style="paddingleft: 20px">
            <el-checkbox v-model="eidtdataForm.changepassword">是否修改密码</el-checkbox>
          </el-col>
        </el-form-item>
        <el-form-item label="原模板密码" prop="oldPassword">
          <el-col :span="15">
            <el-input
              placeholder="请输入密码,无则不填密"
              v-model="eidtdataForm.oldPassword"
              show-password
              size="mini"
            ></el-input>
          </el-col>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="eidtvisible()">取消</el-button>
        <el-button type="primary" @click="eidtFormSubmit()">确定</el-button>
      </span>
    </el-dialog>
    <!-- 重置 -->
    <el-dialog
      :before-close="resetcloseDialog"
      width="500px"
      center
      title="重置密码"
      :close-on-click-modal="false"
      :visible.sync="resetDialogFormVisible"
    >
      <el-form :model="resetdataForm" ref="resetdataForm" :rules="resetRule" label-width="110px">
        <el-form-item label="模板密码" prop="templatePassword">
          <el-col :span="15">
            <el-input
              placeholder="请输入密码"
              v-model="resetdataForm.templatePassword"
              show-password
              size="mini"
            ></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="确认模板密码" prop="confirmtemplatePassword">
          <el-col :span="15">
            <el-input
              placeholder="请输入新密码"
              v-model="resetdataForm.confirmtemplatePassword"
              show-password
              size="mini"
            ></el-input>
          </el-col>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="resetvisible()">取消</el-button>
        <el-button type="primary" @click="resetFormSubmit()">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { JSEncrypt } from 'jsencrypt'
export default {
  data() {
    let checkcreditCardSpaceTime = (rule, value, callback) => {
      // /^(0|[1-9]\d*)(\.\d*)?$/
      let CardSpaceTime = /^(([0-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5]))))$/
      if (!CardSpaceTime.test(value)) {
        callback(new Error('请输入正确的时间格式！'))
      } else {
        callback()
      }
    }
    let resetPassword = (rule, value, callback) => {
      if (this.resetdataForm.templatePassword !== value) {
        callback(new Error('确认密码与新密码不一致'))
      } else {
        callback()
      }
    }
    return {
      isShow: false,
      // 加密
      publicKey:
        'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCx8wyZzYxaffWrJ4jooN554npe5vD2RSQGNXOY5UZz6hcIW0jdEk1KcdclE7mJPiI2DmgUjBp4Lau+bNmZxmLBqFHUMd29mWyqX+LuYVoymxs8f3VJF+7PqZzuKbtSOyXfcyjIIgtB06YlX4SXx4FCErGRx+MDseN2ObHSPme/3wIDAQAB',
      /** 控制隐藏显示效果 */
      leftS: 5,
      rightS: 19,
      isrightS: false,
      isletfS: true,
      // 模板密码
      alldatatemplatePassword: '',
      /** 模板数据 */
      // 当前面板
      activeName: 'third',
      // 正常/补班时段配置面板
      activeNormalPeriod: 'normalWeek',
      // 假日配置子面板second
      activeHoliday: 'holidayVacations',
      // 特殊权限配置
      activeUserSetupList: 'superUserSetupList',
      // 模板列表
      tableData: [],
      // 模板id
      templateGuid: '',
      templateName: '',
      // 模板名称
      adddataForm: {
        templateName: '',
        templatePassword: ''
      },

      // 模板规则
      adddataRule: {
        templateName: [
          { required: true, message: '模板名称不能为空', trigger: 'blur' }
        ]
      },
      // 修改模板弹窗
      eidtDialogFormVisible: false,
      // 修改数据
      eidtdataForm: {
        templateName: '',
        oldPassword: '',
        newPassword: '',
        changepassword: false
      },
      // 重置密码弹窗
      resetDialogFormVisible: false,
      // 重置密码
      resetdataForm: {
        templatePassword: '',
        confirmtemplatePassword: ''
      },
      // 重置密码规则
      resetRule: {
        templatePassword: [
          { required: true, message: '模板密码不能为空', trigger: 'blur' }
        ],
        confirmtemplatePassword: [
          { required: true, message: '确认模板密码不能为空', trigger: 'blur' },
          { validator: resetPassword, trigger: 'blur' }
        ]
      },
      addDialogFormVisible: false,
      // 加载框框
      loading: false,
      /** 基础参数配置 */
      // 进出方向,选项
      doorPassOutOption: [
        { label: '进', value: 0 },
        { label: '出', value: 1 }
      ],
      // 读头韦根类型
      readHeadTypeOption: [
        { label: 'cpu模式', value: 31 },
        { label: 'id模式', value: 32 }
      ],
      // 读头开门验证
      readHeadVerifyOption: [
        { label: '仅卡开门', value: 1 },
        { label: '卡或密码', value: 2 },
        { label: '卡和密码', value: 3 }
      ],
      // 门模式
      doorModelOption: [
        { label: '普通', value: 0 },
        { label: 'AB门', value: 1 },
        { label: '双门双向', value: 2 },
        { label: '单门单向', value: 3 }
      ],
      /**数据满处理方式 0-新数据循环覆盖 1-新数据弃用*/
      dataFullProcessingMethodOption: [
        { label: '循环覆盖', value: 0 },
        { label: '弃用', value: 1 }
      ],
      /**基础设置 */
      ruleForm: {
        //  开门时长
        openingTimeDoor1: 1,
        openingTimeDoor2: 1,

        // 启动按钮
        buttonCheck1: false,
        buttonCheck2: false,

        // 门磁是否启动
        doorMagneticCheck1: false,
        doorMagneticCheck2: false,

        // 门磁类型
        doorMagneticType1: 0,
        doorMagneticType2: 0,

        // 门对应继电器编号
        relayDoorCode1: 1,
        relayDoorCode2: 2,

        // 门对应的进出方向
        doorPassOut1: 0,
        doorPassOut2: 0,

        // 读头对应韦跟类型
        readHeadType1: 0,
        readHeadType2: 0,

        // 读头开门验证
        readHeadVerify1: 1,
        readHeadVerify2: 1,

        // 门对应重新刷卡时间
        doorRepeatSwipeCardTime1: 255,
        doorRepeatSwipeCardTime2: 255,

        // 通行名单卡有效天数开始计算时间
        effectiveStartDate: '2020-01-30',

        // 门模式
        doorModel: 1,

        // 启用AB门
        abdoorEntrance: false,

        // 双门双向防潜回
        twoWayDoor: false,
        /**数据满处理方式 0-新数据循环覆盖 1-新数据弃用*/
        dataFullProcessingMethod: 0,
        /**名单分区字节序号L：0：以第一字节为依据（最高位字节），1：以第二字节为依据，2：以第三字节为依据，3：以第四字节为依据（最低位字节）；*/
        rosterDistrictByteOrder: ''
      },
      rules: {
        icCardPassword: [
          { min: 12, max: 12, message: '必须是12位的卡号', trigger: 'blur' }
        ]
      },
      //
      optionsEntranceStatus: [
        {
          value: 0,
          label: '常闭'
        },
        {
          value: 1,
          label: '常开'
        }
      ],
      /**
       * 门禁状态
       */
      entranceStatusList: [],
      /**
       * 正常/补班时段配置
       */
      /** 正常/补班时段配置 */
      passTimeList: [],
      /** 星期时段配置数据 */
      weekPassTimeList: [],
      /** 假日时段配置数据 */
      holidayPassTimeList: [],
      /**
       * 假日配置
       */
      /**节假日 */
      holidaySetupList: [],
      /** 例外假日配置 */
      holidayOtherList: [],
      /** 周休息日配置 */
      restDay: {},
      /**
       * 特殊权限配置
       */
      // 超级用户.
      superUserSetupList: [],
      // 名单字节分区
      rosterSubareaoption: [
        {
          label: '0',
          value: 0
        },
        {
          label: '1',
          value: 1
        },
        {
          label: '2',
          value: 2
        },
        {
          label: '3',
          value: 3
        }
      ]
    }
  },
  filters: {
    userNumberType(val) {
      if (val >= 4) {
        return `胁迫密码${val - 3}`
      } else {
        return `超级密码${val + 1}`
      }
    }
  },
  created() {
    this.operatorGuid = sessionStorage.getItem('administrator')
    this.userType = sessionStorage.getItem('userType')
  },
  mounted() {
    this.getmodelselect()
    // this.activeName = "first";
  },
  computed: {
    documentClientHeight: {
      get() {
        return this.$store.state.common.documentClientHeight
      }
    },
    changeschoolid: {
      get() {
        return this.$store.state.user.changeschoolid
      }
    }
  },
  methods: {
    leftSClick() {
      this.isrightS = true
      this.leftS = 0
      this.rightS = 24
      this.isletfS = false
    },
    rightSClick() {
      this.isrightS = false
      this.leftS = 5
      this.rightS = 19
      this.isletfS = true
    },
    change(val) {
      console.log(val)
    },
    /**
     * 模板添加
     */
    addtForm() {
      this.addDialogFormVisible = true
    },
    addvisible() {
      this.addDialogFormVisible = false
      this.$refs['adddataForm'].resetFields()
    },
    closeDialog(done) {
      this.$refs['adddataForm'].resetFields()
      done()
    },
    // 新增模板
    addFormSubmit() {
      this.$refs['adddataForm'].validate(valid => {
        if (valid) {
          console.log(this.adddataForm.templatePassword)
          if (
            this.adddataForm.templatePassword === '' ||
            this.adddataForm.templatePassword === null
          ) {
            var templatePassword = ''
          } else {
            let encryptor = new JSEncrypt()
            encryptor.setPublicKey(this.publicKey)
            var templatePassword = encryptor.encrypt(
              this.$md5(this.adddataForm.templatePassword)
            )
          }
          console.log(templatePassword)
          this.$http({
            url: this.$http.adornUrl(
              '/terminal/entrance/entrance-plus-date-parameter-add'
            ),
            method: 'post',
            data: this.$http.adornData({
              messageContent: {
                templateName: this.adddataForm.templateName,
                templatePassword: templatePassword,
                unitGuid: this.changeschoolid
              },
              messageType: this.messageType
            })
          }).then(({ data }) => {
            if (data.messageCode == 200) {
              this.$message({
                showClose: true,
                message: '新增成功',
                type: 'success'
              })
              this.$refs['adddataForm'].resetFields()
              this.getmodelselect()
              this.addDialogFormVisible = false
            } else {
              this.$message({
                showClose: true,
                message: data.errorMessage,
                type: 'error'
              })
            }
          })
        }
      })
    },
    // 获取门锁模板参数列
    getmodelselect() {
      this.$http({
        url: this.$http.adornUrl('/terminal/template-model-select'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            terminalType: 23,
            unitGuid: this.changeschoolid
          },
          messageType: this.messageType
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          console.log(data)
          this.tableData = data.messageContent
        } else {
          this.$message({
            showClose: true,
            message: data.errorMessage,
            type: 'error'
          })
        }
      })
    },

    // 点击当前模板触发
    rowClick(row) {
      // 模板信息
      this.isShow = true
      console.log(row)
      this.templateGuid = row.templateGuid
      this.templateName = row.templateName
      this.getLockList()
    },
    /**
     * 模板修改
     */

    // 修改模板
    eidtDate(row) {
      this.eidtDialogFormVisible = true
      this.eidtdataForm.changepassword = false
      this.eidtdataForm.templateGuid = row.templateGuid
      this.$set(this.eidtdataForm, 'templateName', row.templateName)
      console.log(row)
    },
    eidtcloseDialog(done) {
      this.$refs['eidtdataForm1'].resetFields()

      done()
    },
    // 取消修改
    eidtvisible() {
      this.$refs['eidtdataForm1'].resetFields()

      this.eidtDialogFormVisible = false
    },
    // 确定修改
    eidtFormSubmit() {
      this.$refs['eidtdataForm1'].validate(valid => {
        if (valid) {
          if (
            this.eidtdataForm.oldPassword === '' ||
            this.eidtdataForm.oldPassword === null
          ) {
            var oldPassword = ''
          }
          if (
            this.eidtdataForm.newPassword === '' ||
            this.eidtdataForm.newPassword === null
          ) {
            var newPassword = ''
          }
          if (
            this.eidtdataForm.oldPassword !== '' &&
            this.eidtdataForm.oldPassword !== null
          ) {
            let encryptor = new JSEncrypt()
            encryptor.setPublicKey(this.publicKey)
            var oldPassword = encryptor.encrypt(
              this.$md5(this.eidtdataForm.oldPassword)
            )
          }
          if (
            this.eidtdataForm.newPassword !== '' &&
            this.eidtdataForm.newPassword !== null
          ) {
            let encryptor = new JSEncrypt()
            encryptor.setPublicKey(this.publicKey)
            var newPassword = encryptor.encrypt(
              this.$md5(this.eidtdataForm.newPassword)
            )
          }
          if (this.eidtdataForm.changepassword == false) {
            var newPassword = null
          }
          this.$http({
            url: this.$http.adornUrl('/terminal/template-update-password'),
            method: 'post',
            data: this.$http.adornData({
              messageContent: {
                newPassword: newPassword,
                oldPassword: oldPassword,
                unitGuid: this.changeschoolid,
                templateName: this.eidtdataForm.templateName,
                templateGuid: this.eidtdataForm.templateGuid,
                terminalType: 23
              },
              messageType: this.messageType
            })
          }).then(({ data }) => {
            if (data.messageCode == 200) {
              this.$message({
                showClose: true,
                message: '修改成功',
                type: 'success'
              })
              this.getmodelselect()
              this.$refs['eidtdataForm1'].resetFields()
              this.eidtDialogFormVisible = false
            } else {
              this.$message({
                showClose: true,
                message: data.errorMessage,
                type: 'error'
              })
            }
          })
        }
      })
    },
    /**
     * 模板重置
     */
    resetDate(row) {
      console.log(row)
      this.resetdataForm.templateGuid = row.templateGuid
      this.resetDialogFormVisible = true
    },
    resetvisible() {
      this.resetDialogFormVisible = false
      this.$refs['resetdataForm'].resetFields()
    },
    resetcloseDialog(done) {
      this.$refs['resetdataForm'].resetFields()
      done()
    },
    resetFormSubmit() {
      this.$refs['resetdataForm'].validate(valid => {
        if (valid) {
          let encryptor = new JSEncrypt()
          encryptor.setPublicKey(this.publicKey)
          let confirmtemplatePassword = encryptor.encrypt(
            this.$md5(this.resetdataForm.confirmtemplatePassword)
          )
          this.$http({
            url: this.$http.adornUrl('/terminal/template-reset-password'),
            method: 'post',
            data: this.$http.adornData({
              messageContent: {
                templatePassword: confirmtemplatePassword,
                templateGuid: this.resetdataForm.templateGuid,
                unitGuid: this.changeschoolid,
                operatorGuid: this.operatorGuid
              },
              messageType: this.messageType
            })
          }).then(({ data }) => {
            if (data.messageCode == 200) {
              this.$message({
                showClose: true,
                message: '重置成功',
                type: 'success'
              })
              this.getmodelselect()
              this.$refs['resetdataForm'].resetFields()
              this.resetDialogFormVisible = false
            } else {
              this.$message({
                showClose: true,
                message: data.errorMessage,
                type: 'error'
              })
            }
          })
        }
      })
    },

    /**
     * 模板删除
     */
    // 删除模板
    deleteDate(row) {
      this.$prompt('请输入密码,无则不输入', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      })
        .then(({ value }) => {
          if (value !== null && value !== '') {
            let templatePassword = value
            let encryptor = new JSEncrypt()
            encryptor.setPublicKey(this.publicKey)
            templatePassword = encryptor.encrypt(this.$md5(templatePassword))
            this.deletconsumptiondata(row, templatePassword)
          } else {
            let templatePassword = ''
            this.deletconsumptiondata(row, templatePassword)
          }
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '取消输入'
          })
        })
    },
    //删除模板数据
    deletconsumptiondata(row, templatePassword) {
      this.$http({
        url: this.$http.adornUrl('/terminal/consume/consume-parameter-delete'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            templateGuid: row.templateGuid,
            unitGuid: this.changeschoolid,
            templatePassword: templatePassword
          },
          messageType: 0
        })
      }).then(({ data }) => {
        console.log(data)
        if (data.messageCode == 200) {
          this.$message({
            type: 'success',
            message: '删除成功'
          })
          this.getmodelselect()
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },
    // 门锁参数模板查询
    getLockList() {
      this.$http({
        url: this.$http.adornUrl(
          '/terminal/entrance/entrance-plus-date-parameter-search'
        ),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            templateGuid: this.templateGuid,
            unitGuid: this.changeschoolid
          },
          messageType: this.messageType
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          console.log(data.messageContent)
          //  开门时长
          this.$set(
            this.ruleForm,
            'openingTimeDoor1',
            data.messageContent.openingTimeDoor1
          )
          this.$set(
            this.ruleForm,
            'openingTimeDoor2',
            data.messageContent.openingTimeDoor2
          )
          this.$set(
            this.ruleForm,
            'openingTimeDoor3',
            data.messageContent.openingTimeDoor3
          )
          this.$set(
            this.ruleForm,
            'openingTimeDoor4',
            data.messageContent.openingTimeDoor4
          )

          // // 启动按钮
          this.$set(
            this.ruleForm,
            'buttonCheck1',
            data.messageContent.buttonCheck1
          )
          this.$set(
            this.ruleForm,
            'buttonCheck2',
            data.messageContent.buttonCheck2
          )

          // // 门磁是否启动
          this.$set(
            this.ruleForm,
            'doorMagneticCheck1',
            data.messageContent.doorMagneticCheck1
          )
          this.$set(
            this.ruleForm,
            'doorMagneticCheck2',
            data.messageContent.doorMagneticCheck2
          )

          // // 门磁类型
          this.$set(
            this.ruleForm,
            'doorMagneticType1',
            data.messageContent.doorMagneticType1
          )
          this.$set(
            this.ruleForm,
            'doorMagneticType2',
            data.messageContent.doorMagneticType2
          )

          // // 门对应继电器编号
          this.$set(
            this.ruleForm,
            'relayDoorCode1',
            data.messageContent.relayDoorCode1
          )
          this.$set(
            this.ruleForm,
            'relayDoorCode2',
            data.messageContent.relayDoorCode2
          )

          // // 门对应的进出方向
          this.$set(
            this.ruleForm,
            'doorPassOut1',
            data.messageContent.doorPassOut1
          )
          this.$set(
            this.ruleForm,
            'doorPassOut2',
            data.messageContent.doorPassOut2
          )

          // // 读头对应韦跟类型
          this.$set(
            this.ruleForm,
            'readHeadType1',
            data.messageContent.readHeadType1
          )
          this.$set(
            this.ruleForm,
            'readHeadType2',
            data.messageContent.readHeadType2
          )

          // // 读头开门验证
          this.$set(
            this.ruleForm,
            'readHeadVerify1',
            data.messageContent.readHeadVerify1
          )
          this.$set(
            this.ruleForm,
            'readHeadVerify2',
            data.messageContent.readHeadVerify2
          )

          // // 门对应重新刷卡时间
          this.$set(
            this.ruleForm,
            'doorRepeatSwipeCardTime1',
            data.messageContent.doorRepeatSwipeCardTime1
          )
          this.$set(
            this.ruleForm,
            'doorRepeatSwipeCardTime2',
            data.messageContent.doorRepeatSwipeCardTime2
          )

          // // 通行名单卡有效天数开始计算时间
          this.$set(
            this.ruleForm,
            'effectiveStartDate',
            data.messageContent.effectiveStartDate
          )

          // // 门模式
          this.$set(this.ruleForm, 'doorModel', data.messageContent.doorModel)

          // // 启用AB门
          this.$set(
            this.ruleForm,
            'abdoorEntrance',
            data.messageContent.abdoorEntrance
          )

          // // 双门双向防潜回
          this.$set(this.ruleForm, 'twoWayDoor', data.messageContent.twoWayDoor)
          /**数据满处理方式 0-新数据循环覆盖 1-新数据弃用*/
          this.$set(
            this.ruleForm,
            'dataFullProcessingMethod',
            data.messageContent.dataFullProcessingMethod
          )
          /**名单分区字节序号L：0：以第一字节为依据（最高位字节），1：以第二字节为依据，2：以第三字节为依据，3：以第四字节为依据（最低位字节）；*/
          this.$set(
            this.ruleForm,
            'rosterDistrictByteOrder',
            data.messageContent.rosterDistrictByteOrder
          )
          /**
           * 门禁状态
           */
          this.entranceStatusList = data.messageContent.entranceStatusList

          /**
           * 正常/补班时段配置
           */
          this.passTimeList = data.messageContent.passTimeList
          // 星期时段配置
          this.weekPassTimeList = data.messageContent.weekPassTimeList
          // 假日时段配置
          this.holidayPassTimeList = data.messageContent.holidayPassTimeList

          /**
           * 假日配置
           */
          // 节假日配置
          this.holidaySetupList = data.messageContent.holidaySetupList
          // 例外假日配置
          this.holidayOtherList = data.messageContent.holidayOtherList
          // 周休息日配置
          this.restDay = data.messageContent.restDay

          /**
           * 特殊权限配置
           */
          // 超级用户
          this.superUserSetupList = data.messageContent.superUserSetupList

          this.$message({
            showClose: true,
            message: '查询成功',
            type: 'success'
          })
        } else {
          this.$message({
            showClose: true,
            message: data.errorMessage,
            type: 'error'
          })
        }
      })
    },
    tishi(arr, str) {
      if (arr.length > 0) {
        let isKey = true
        let keyArr = Object.keys(arr[0])
        console.log(arr)
        arr.map(item => {
          keyArr.map(key => {
            if (item[key] == null) {
              this.$message({
                showClose: true,
                message: `请选择${str}时间`,
                type: 'warning'
              })
              isKey = false
              return isKey
            }
          })
        })
        return isKey
      }
    },
    // 保存按钮,修改数据
    savealldata() {
      if (this.templateGuid == '') {
        this.$message({
          showClose: true,
          message: '请选择模块',
          type: 'warning'
        })
        return false
      }
      // 限制
      if (this.ruleForm.effectiveStartDate === null) {
        this.$message({
          showClose: true,
          message: '通行名单卡有效天数开始计算时间不能为空',
          type: 'warning'
        })
        return false
      }
      if (!this.tishi(this.entranceStatusList, '门禁状态')) {
        return false
      }
      if (!this.tishi(this.passTimeList, '正常/补班时段配置')) {
        return false
      }
      if (!this.tishi(this.weekPassTimeList, '星期时段配置')) {
        return false
      }
      if (!this.tishi(this.holidayPassTimeList, '假日时段配置')) {
        return false
      }
      if (!this.tishi(this.holidaySetupList, '节假日')) {
        return false
      }
      if (!this.tishi(this.holidayOtherList, '例外假日')) {
        return false
      }

      // if(!this.tishi(this.holidaySetupList)){
      //   return false;
      // }
      let parameterData = {}
      parameterData = { ...this.ruleForm }
      console.log(parameterData.doorMagneticCheck1)
      /**
       * 正常/补班时段配置
       */
      parameterData.passTimeList = this.passTimeList
      // 星期时段配置
      parameterData.weekPassTimeList = this.weekPassTimeList
      // 假日时段配置
      parameterData.holidayPassTimeList = this.holidayPassTimeList
      /**
       * 假日配置
       */
      // 节假日配置
      parameterData.holidaySetupList = this.holidaySetupList
      // 例外假日配置
      parameterData.holidayOtherList = this.holidayOtherList
      // 周休息日配置
      parameterData.restDay = this.restDay
      /**
       * 门禁状态
       */
      parameterData.entranceStatusList = this.entranceStatusList
      /**
       * 特殊权限配置
       */
      // 超级用户
      parameterData.superUserSetupList = this.superUserSetupList

      // 模板密码处理
      if (
        this.alldatatemplatePassword !== '' &&
        this.alldatatemplatePassword !== null
      ) {
        var templatePassword1 = this.alldatatemplatePassword
        let encryptor = new JSEncrypt()
        encryptor.setPublicKey(this.publicKey)
        templatePassword1 = encryptor.encrypt(this.$md5(templatePassword1))
      }
      this.editParametter(parameterData, templatePassword1)
    },
    editParametter(parameterData, templatePassword1) {
      this.$http({
        url: this.$http.adornUrl(
          '/terminal/entrance/entrance-plus-date-parameter-update'
        ),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            parameterData: parameterData,
            // 当前操作的模板id
            templateGuid: this.templateGuid,
            // 当前操作模板
            // templateName: this.templateName,
            // 学校id
            unitGuid: this.changeschoolid,
            templatePassword: templatePassword1
          },
          messageType: this.messageType
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          this.$message({
            showClose: true,
            message: '保存成功',
            type: 'success'
          })
          console.log(data)
        } else {
          this.$message({
            showClose: true,
            message: data.errorMessage,
            type: 'error'
          })
        }
      })
    },
    // 下发参数
    savemerchant() {
      if (this.templateGuid == null || this.templateGuid == '') {
        this.$message({
          type: 'warning',
          message: '请选择参数模板!'
        })
        return
      }
      this.$confirm('是否重发该模板的参数?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.$http({
            url: this.$http.adornUrl('/terminal/reset-template'),
            method: 'post',
            data: this.$http.adornData({
              messageContent: {
                templateGuid: this.templateGuid,
                unitGuid: this.changeschoolid
              },
              messageType: 0
            })
          }).then(({ data }) => {
            if (data.messageCode == 200) {
              this.$message({
                type: 'success',
                message: '下发成功'
              })
            } else {
              this.$message.error(data.errorMessage)
            }
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    //卡片切换
    handleClick() {},
    handleNormalPeriod() {},
    // 假日配置卡片切换
    handleSecond() {}
  }
}
</script>

<style lang="scss" scoped>
.grid-content.bg-purple-light {
  .el-form-item {
    margin-bottom: 0;
  }
}
.consumer_machine {
  /deep/.el-table {
    /deep/tbody tr:hover > td {
      cursor: pointer;
    }
  }
  //滚动条的宽度
  ::-webkit-scrollbar {
    width: 15px;
    height: 15px;
  }
  //滚动条的滑块
  ::-webkit-scrollbar-thumb {
    background-color: #a1a3a9;
    border-radius: 3px;
  }
  // /deep/.el-tabs--border-card > .el-tabs__content{
  //   height: 62vh;
  //   // overflow: auto;
  // }
  .el-row {
    margin-bottom: 5px;
    &:last-child {
      margin-bottom: 0;
    }
    .grid-content {
      .picker_width {
        width: 150px;
      }
      .header_title,
      .addtemplate {
        padding: 20px 0;
        font-weight: bolder;
        padding-left: 20px;
        border-bottom: 1px solid #e5e9f2;
        color: #909399;
        text-align: center;
        overflow: hidden;
      }
      .addtemplate {
        padding: 5px;
      }
    }
    .bg-purple {
      height: 100%;
      // background: #d3dce6;
      height: auto;
    }
    .bg-purple-light {
      // padding: 10px 0px 0 0;
      padding-top:35px;
      .explanation .el-table th,
      .hostForm .el-table tr {
        font-weight: normal;
      }
      .margintoppx {
        margin-top: 20px;
      }
      .demo-form-inline,
      .demo-form-inline1 {
        padding-bottom: 20px;
        display: flex;
        /deep/.el-form-item__label {
          padding-right: 5px;
        }
        .el-radio + .el-radio {
          margin-right: 0px;
        }
        .el-form-item {
          margin-bottom: 0px;
        }
        .el-date-editor.el-input,
        .el-date-editor.el-input__inner {
          width: 100%;
        }
        .el-row {
          width: 100%;
        }
        .shi_jian_zhi,
        .xuan_zhe,
        .danxuan {
          display: flex;
          justify-content: center;
        }
      }
      .demo-form-inline1 {
        border-bottom: 1px solid #e5e9f2;
        .searchmarigin {
          margin-left: 20px;
        }
      }
      .consumption_rules {
        // padding: 20px;
        background-color: #f5f5f5;
      }
      .footer {
        height: 60px;
        display: flex;
        align-items: center;
        .el-card.is-always-shadow,
        .el-card.is-hover-shadow:focus,
        .el-card.is-hover-shadow:hover {
          width: 100%;
          height: 80%;
        }
      }
    }
  }
}
</style>